import time

from common.Tools import Tools
from page.general import General


class SecretBase(General, metaclass=Tools):
    SECRET_BASE = 'secret_base.jpg'
    SECRET_BASE_MATERIALS = 'secret_base_materials.jpg'

    def click_secret_base(self):
        return self.click_match_xy(self.SECRET_BASE)

    def click_secret_base_material(self):
        return self.click_match_xy(self.SECRET_BASE_MATERIALS, 'all')

    def receive_all_material(self):
        self.click_secret_base()
        while not self.get_match_xy(self.SECRET_BASE_MATERIALS):
            time.sleep(2)
        while self.get_match_xy(self.SECRET_BASE_MATERIALS):
            self.click_secret_base_material()
            self.click_close()
        self.driver.back()
